<script setup lang="ts">
import {useSysUserStore} from './stores/user.ts'
const useSysUser = useSysUserStore()

// 定义你的初始用户数据
const initialUsers = [
  {
    id: Date.now(),
    router: 'admin',
    token: 'fake-jwt-token-' + Math.random().toString(36).substring(2),
    username: 'admin',
    password: 'admin123',
    name: 'John Doe',
    age: 30,
    gender: '男',
    createTime: new Date().toISOString(),
    updateTime: new Date().toISOString(),
    imgUrl: '',
    studengOrteacherId: 101,
  },
  {
    id: Date.now() + 1,
    router: 'student',
    token: 'fake-jwt-token-' + Math.random().toString(36).substring(2),
    username: 'student',
    password: 'student123',
    name: 'Jane Student',
    age: 20,
    gender: '女',
    createTime: new Date().toISOString(),
    updateTime: new Date().toISOString(),
    imgUrl: '',
    studengOrteacherId: 102,
  },
  {
    id: Date.now() + 2,
    router: 'teacher',
    token: 'fake-jwt-token-' + Math.random().toString(36).substring(2),
    username: 'teacher',
    password: 'teacher123',
    name: 'Mr. Smith Teacher',
    age: 45,
    gender: '男',
    createTime: new Date().toISOString(),
    updateTime: new Date().toISOString(),
    imgUrl: '',
    studengOrteacherId: 103,
  },
];
if (useSysUser.sysUser.length === 0) {
  console.log('本地存储为空，正在初始化默认用户数据...');
  initialUsers.forEach(user => {
    useSysUser.setUserInfo(user);
  });
} else {
  console.log('检测到本地存储中已有用户数据，跳过初始化。');
  console.log('当前用户数据:', useSysUser.sysUser);
}

</script>

<template>
  <n-message-provider>
    <router-view />
  </n-message-provider>

</template>

<style>
body{
  padding: 0;
  margin: 0;
}
</style>
